﻿<script id="confirmTemplate" type="text/x-jquery-tmpl">
    <p>${}</p>
</script>
<script type="text/javascript">
    $(function () {
        $('#confirmTemplate').data('handler-load', function (tmplItem) {
            // validate input parameter(s)
            if (tmplItem == null || tmplItem.nodes.length == 0) { return; }
            // extend tmplItem
            $extendTmplItem(tmplItem);
            // initialize current template item
            var container = $(tmplItem.nodes[0]).parent();
            container.attr('title', 'Confirmation');
            // bind events
            tmplItem.on('showDialog', function (event, onSubmit) {
                container.dialog({
                    autoOpen: true, height: 200, width: 400, modal: true,
                    buttons: {
                        'Yes, I confirm.': function () {
                            if (typeof (onSubmit) == 'function') { onSubmit(); }
                            $(this).dialog('close');
                        },
                        'No.': function () { $(this).dialog('close'); }
                    },
                    close: function () { }
                });
            });
        });
    });
</script>
<script id="messageTemplate" type="text/x-jquery-tmpl">
    <p>${}</p>
</script>
<script type="text/javascript">
    $(function () {
        $('#messageTemplate').data('handler-load', function (tmplItem) {
            // validate input parameter(s)
            if (tmplItem == null || tmplItem.nodes.length == 0) { return; }
            // extend tmplItem
            $extendTmplItem(tmplItem);
            // initialize current template item
            var container = $(tmplItem.nodes[0]).parent();
            if (container.attr('title') == null) { container.attr('title', 'Message'); }
            // bind events
            tmplItem.on('showDialog', function (event, onSubmit) {
                container.dialog({
                    autoOpen: true, height: 200, width: 400, modal: true,
                    buttons: {
                        'OK': function () { $(this).dialog('close'); }
                    }
                });
            });
        });
    });
</script>